package com.goose.bmm.controler.adapter;

import com.goose.bmm.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SlidingMenuAdapter extends BaseAdapter {

	private String[] items;
	private Activity mActivity;
	private LayoutInflater mLayoutInflater;

	public SlidingMenuAdapter(Activity mActivity) {
		this.mActivity = mActivity;
		items = this.mActivity.getResources().getStringArray(
				R.array.sliding_menu_items);
		mLayoutInflater = (LayoutInflater) this.mActivity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return items[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup viewGroup) {
		if (items[position].contains("+")) { // setup for item success
			convertView = mLayoutInflater.inflate(
					R.layout.item_list_menu_success, null);
			TextView textView = (TextView) convertView
					.findViewById(R.id.tv_item_success);
			textView.setText(items[position]);
		} else if (items[position].contains("-")) { // setup for item mistake
			convertView = mLayoutInflater.inflate(
					R.layout.item_list_menu_mistake, null);
			TextView textView = (TextView) convertView
					.findViewById(R.id.tv_item_mistake);
			textView.setText(items[position]);
		} else { // setup for item textview
			convertView = mLayoutInflater.inflate(
					R.layout.item_text_divide_menu, null);
			TextView textView = (TextView) convertView
					.findViewById(R.id.tv_item_divide);
			textView.setText(items[position]);
		}

		return convertView;
	}

}
